<?php

namespace App\Http\Controllers\Shop\Business;

use App\Http\Controllers\ShopController;
use App\Models\Business\Collection as CollectionModel;


class CollectionController extends ShopController
{

    public function index()
    {
        $busid = request('busid',0);
        $page = request('page',1);
        $limit = request('limit',10);
        $start = ($page - 1) * $limit;
        // $content = '<p>小程序开发<br></p>';
        $list = CollectionModel::with('product')->where(['busid'=>$busid])->where('proid','!=','')->orderBy('createtime','desc')->offset($start)->limit($limit)->get();
        $listCount = CollectionModel::with('product')->where(['busid'=>$busid])->where('proid','!=','')->count();
        // $list=strip_tags($list);
        // dd($content);
        
        $data = [
            'count' => $listCount,
            'list' => $list
        ];

        if($list){
            return $this->success('查询成功',$data);
        }else{
            return $this->error('查询失败',[]);
        }
    }



    public function del(){
        $busid = request('busid',0);
        $proid = request('proid',0);
        $result = CollectionModel::where('busid',$busid)->where('proid',$proid)->delete();
        if($result === false)
        {
            return $this->error('取消失败');
        }else{
            return $this->success('取消成功');
        }
    }

    

}